<?php

$timezone = date_default_timezone_get();
echo "The current server timezone is: " . $timezone . "<br />";
$date = date('m/d/Y h:i:s a', time());
echo $date . "<br />";
echo dirname(__FILE__);
phpinfo();


function foldersize($path) {
    $total_size = 0;
    $files = scandir($path);
    $cleanPath = rtrim($path, '/'). '/';

    foreach($files as $t) {
        if ($t<>"." && $t<>"..") {
            $currentFile = $cleanPath . $t;
            if (is_dir($currentFile)) {
                $size = foldersize($currentFile);
                $total_size += $size;
            }
            else {
                $size = filesize($currentFile);
                $total_size += $size;
            }
        }   
    }

    return $total_size;
}

function roundsize($size){
    $i=0;
    $iec = array("B", "Kb", "Mb", "Gb", "Tb");
    while (($size/1024)>1) {
        $size=$size/1024;
        $i++;
	}
	//echo $i;
    return(round($size,1)." ".$iec[$i]);
}

function dirSize($directory) {
    $size = 0;
    foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file){
        $size+=$file->getSize();
    }
    return $size;
} 
$product_path = dirname(__FILE__) . '/administrator';
$total_product_size = dirSize($product_path);
echo  $product_path . ": " . roundsize($total_product_size);
echo "<br />";

$product_path = dirname(__FILE__) . '/application';
$total_product_size = dirSize($product_path);
echo  $product_path . ": " . roundsize($total_product_size);
echo "<br />";

$product_path = dirname(__FILE__) . '/assets';
$total_product_size = dirSize($product_path);
echo  $product_path . ": " . roundsize($total_product_size);
echo "<br />";

$product_path = dirname(__FILE__) . '/cache';
$total_product_size = dirSize($product_path);
echo  $product_path . ": " . roundsize($total_product_size);
echo "<br />";

$product_path = dirname(__FILE__) . '/campaignsrc';
$total_product_size = dirSize($product_path);
echo  $product_path . ": " . roundsize($total_product_size);
echo "<br />";

$product_path = dirname(__FILE__) . '/components';
$total_product_size = dirSize($product_path);
echo  $product_path . ": " . roundsize($total_product_size);
echo "<br />";

$product_path = dirname(__FILE__) . '/images';
$total_product_size = dirSize($product_path);
echo  $product_path . ": " . roundsize($total_product_size);
echo "<br />";

$product_path = dirname(__FILE__) . '/media';
$total_product_size = dirSize($product_path);
echo  $product_path . ": " . roundsize($total_product_size);
echo "<br />";

$product_path = dirname(__FILE__) . '/templates';
$total_product_size = dirSize($product_path);
echo  $product_path . ": " . roundsize($total_product_size);
echo "<br />";

$product_path = dirname(__FILE__) . '/application';
$total_product_size = dirSize($product_path);
echo  $product_path . ": " . roundsize($total_product_size);
echo "<br />";


?>